import 'package:chewie/chewie.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';

class VideoFullPlayerPage extends GetView<VideoFullPlayerController> {
  const VideoFullPlayerPage({Key? key}) : super(key: key);

  // 主视图
  Widget _buildView() {
    final state = controller.state;
    if (state.controller == null) {
      return const Center(
        child: CupertinoActivityIndicator(),
      );
    }
    return Chewie(controller: state.controller!);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<VideoFullPlayerController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: Text(controller.state.title)),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
